package com.example.demo.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.example.demo.common.Result;
import com.example.demo.entity.WebPage2User;
import com.example.demo.entity.WebPage3User;
import com.example.demo.mapper.WebPage3UserMapper;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/webpage3")
//碰到user
public class Page3Controller {
    @Resource
    WebPage3UserMapper webPage3UserMapper;

    @PostMapping
    public Result<?> save(@RequestBody WebPage3User webPage3User){
        webPage3UserMapper.insert(webPage3User);
        return Result.success();
    }
    @PutMapping
    public Result<?> update(@RequestBody WebPage3User webPage3User){
        webPage3UserMapper.updateById(webPage3User);
        return Result.success();
    }
    @GetMapping
    public List<WebPage3User> selectList(@RequestParam int search){
        LambdaQueryWrapper<WebPage3User> wrapper= Wrappers.<WebPage3User>lambdaQuery();
        wrapper.eq(WebPage3User::getPageId,search);
        return webPage3UserMapper.selectList(wrapper);
    }
    @GetMapping("/pageId={id}")
    public WebPage3User selectById(@PathVariable Long id){
        return webPage3UserMapper.selectById(id);
    }
    @DeleteMapping("/{id}")
    public Result<?> update (@PathVariable Long id){
        webPage3UserMapper.deleteById(id);
        return Result.success();
    }

}
